package com.dolphin.apipassenger.constraints;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;
import java.util.List;

public class VehicleTypeCheckValidator implements ConstraintValidator<VehicleTypeValidator, String> {
    private List<String> vehicleTypeCheckValue;

    @Override
    public void initialize(VehicleTypeValidator constraintAnnotation) {
        vehicleTypeCheckValue = Arrays.asList(constraintAnnotation.vehicleTypeValue());

        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {

        if (vehicleTypeCheckValue.contains(value)){
            return true;
        }
        return false;
    }
}
